﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="产品销售价格收入月报.aspx.cs" Inherits="syc.Produce.Report.产品销售价格收入月报" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript" src="/common.js"></script>
    <style>
        th {height:30px;vertical-align:middle; text-align:center;}
        td {height:30px;vertical-align:middle; text-align:center;}

        .style1
        {
            width: 70px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
     <div>
     
        <div class="hooo">
        <div id="wintop" class="wintop"><span lang="zh-cn"><u>产品销售价格收入月报</u></span></div>
        <asp:Panel ID="Panel1" runat="server" CssClass="panel" Height="36px">
  
        <table>
        <tr id="row2" runat="server">
        <td>
        年份:
        </td>
        <td>
        <asp:DropDownList ID="DList_year" runat="server" AutoPostBack="True" 
                onselectedindexchanged="DList_year_SelectedIndexChanged">
            <asp:ListItem>2009</asp:ListItem>
            <asp:ListItem>2010</asp:ListItem>
            <asp:ListItem>2011</asp:ListItem>
            <asp:ListItem>2012</asp:ListItem>
            <asp:ListItem>2013</asp:ListItem>
            <asp:ListItem>2014</asp:ListItem>
            <asp:ListItem>2015</asp:ListItem>
            <asp:ListItem></asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
        月份:
        </td>
        <td class="style1">
        <asp:DropDownList ID="DList_month" runat="server" AutoPostBack="True" 
                onselectedindexchanged="DList_month_SelectedIndexChanged">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>5</asp:ListItem>
            <asp:ListItem>6</asp:ListItem>
            <asp:ListItem>7</asp:ListItem>
            <asp:ListItem>8</asp:ListItem>
            <asp:ListItem>9</asp:ListItem>
            <asp:ListItem>10</asp:ListItem>
            <asp:ListItem>11</asp:ListItem>
            <asp:ListItem>12</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td> <asp:Button ID="Button_Query"
            runat="server" Text="查看报表" CssClass="button" UseSubmitBehavior="true" onclick="Button_Query_Click"  Visible="false"
             />
            <asp:Button ID="Button_Save" runat="server" Text="导出报表" CssClass="button" 
                UseSubmitBehavior="False" onclick="Button_Save_Click"/></td>
        </tr>
        </table>
        
        </asp:Panel>
        <asp:Panel ID="Panel2" runat="server" CssClass="panel2">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt" Visible="True"></asp:Label>
        </asp:Panel> 
    
        <h1 style="text-align: center;">
            <%=DList_year.SelectedItem.Text %>年<%=DList_month.SelectedItem.Text %>月产品销售价格收入月报</h1>
        <div align="center">
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"  ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
         SelectCommand="SELECT
--品名
      '油管' AS 品名, 
--本月销量
	  [销售量] AS 本月销量,
--累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=1
	   ) AS 累计销量,	     
--本月平均
      [平均价] AS 本月平均,
--累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=1
	   ) AS 累计平均,     
--销售收入
      [销售收入] AS 本月收入,
--累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=1
	   ) AS 累计销售收入,
--上年同期量
	 (SELECT [销售量] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=1
	 )AS 上年销售量,
--上年同期价
	 (SELECT [平均价] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=1
	 )AS 上年平均价,
--上年同期收入
	 (SELECT [销售收入] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=1
	 )AS 上年销售收入,
--上年累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=1
	   ) AS 上年累计销量,	     
--上年累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=1
	   ) AS 上年累计平均,     
--上年累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=@月份
	   ) AS 上年累计销售收入	 	  	  	   	
FROM [销售收入]
WHERE [年份]=@年份 AND [月份]=@月份 AND 产品ID=1
union all
SELECT 
--品名
      '套管' AS 品名,
--本月销量
	  [销售量] AS 本月销量,
--累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 累计销量,	     
--本月平均
      [平均价] AS 本月平均,
--累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 累计平均,     
--销售收入
      [销售收入] AS 本月收入,
--累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 累计销售收入,
--上年同期量
	 (SELECT [销售量] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=2
	 )AS 上年销售量,
--上年同期价
	 (SELECT [平均价] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=2
	 )AS 上年平均价,
--上年同期收入
	 (SELECT [销售收入] FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 AND 产品ID=2
	 )AS 上年销售收入,
--上年累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 上年累计销量,	     
--上年累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 上年累计平均,     
--上年累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 AND 产品ID=2
	   ) AS 上年累计销售收入	 	  	  	   	
FROM [销售收入]
WHERE [年份]=@年份 AND [月份]=@月份 AND 产品ID=2
union all
SELECT 
--品名
      '合计' AS 品名,
--本月销量
	  SUM([销售量]) AS 本月销量,
--累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 
	   ) AS 累计销量,	     
--本月平均
      AVG([平均价]) AS 本月平均,
--累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 
	   ) AS 累计平均,     
--销售收入
      SUM([销售收入]) AS 本月收入,
--累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份 AND [月份]<=@月份 
	   ) AS 累计销售收入,
--上年同期量
	 (SELECT SUM([销售量]) FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 
	 )AS 上年销售量,
--上年同期价
	 (SELECT AVG([平均价]) FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 
	 )AS 上年平均价,
--上年同期收入
	 (SELECT SUM([销售收入]) FROM [销售收入]
	 WHERE [年份]=@年份-1 AND [月份]=@月份 
	 )AS 上年销售收入,
--上年累计销量
	  (SELECT SUM([销售量])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份
	   ) AS 上年累计销量,	     
--上年累计平均 
	  (SELECT AVG([平均价])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份 
	   ) AS 上年累计平均,     
--上年累计销售收入
	  (SELECT SUM([销售收入])
	   FROM [销售收入]
	   WHERE [年份]=@年份-1 AND [月份]<=@月份
	   ) AS 上年累计销售收入	 	  	  	   	
FROM [销售收入]
WHERE [年份]=@年份 AND [月份]=@月份" DataSourceMode="DataReader">
        <SelectParameters>
            <asp:ControlParameter ControlID="DList_year" PropertyName="SelectedValue" Name="年份" Type="Int32" />
            <asp:ControlParameter ControlID="DList_month" PropertyName="SelectedValue" Name="月份" Type="Int32" />
        </SelectParameters>
        </asp:SqlDataSource>
        <asp:Repeater DataSourceID="SqlDataSource1" ID="Repeater1" runat="server">
        <HeaderTemplate>
                  <table class="table_border" border="2" cellpadding="0" cellspacing="0" width="1000px">
        <tr align="center">
            <th rowspan="2">品种</th><th colspan="2">销售量</th>
            <th colspan="2">平均价</th><th colspan="2">销售收入</th>
            <th colspan="3">上年同期</th><th colspan="3">上年同期累计</th>
        </tr>
        <tr>
            <td>本月</td><td>累计</td><td>本月</td><td>累计</td><td>本月</td><td>累计</td>
            <td>销售量</td><td>平均价</td><td>销售收入</td><td>销售量</td><td>平均价</td><td>销售收入</td>
        </tr>      
        </HeaderTemplate>
        
        
        <ItemTemplate>

        <tr>
            <td><%# Eval("品名") %></td>
            <td><%# Eval("本月销量") %></td>
            <td><%# Eval("累计销量") %></td>
            <td><%# Eval("本月平均","{0:C}") %></td>
            <td><%# Eval("累计平均","{0:C}") %></td>
            <td><%# Eval("本月收入", "{0:C}")%></td>
            <td><%# Eval("累计销售收入", "{0:C}")%></td>
            <td><%# Eval("上年销售量") %></td>
            <td><%# Eval("上年平均价", "{0:C}")%></td>
            <td><%# Eval("上年销售收入", "{0:C}")%></td>
            <td><%# Eval("上年累计销量") %></td>
            <td><%# Eval("上年累计平均", "{0:C}")%></td>
            <td><%# Eval("上年累计销售收入", "{0:C}")%></td>
        </tr>
        
 
         </ItemTemplate>
         
         
         <FooterTemplate>
        <tr>
                       <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
            <td></td><td></td><td></td>
        </tr>    
        <tr>
            <td>备注</td><td colspan="12"></td>
        </tr>                                                                                                        
        </table>
            </FooterTemplate>
        </asp:Repeater>
        
        </div>   
    </div>
    </form>
<script>parent.hidesubmenu(true);</script>
</body>
</html>
